#define _CRT_SECURE_NO_WARNINGS 1     
#pragma once
#include"Hash.h"
namespace sqy
{
	template<class K, class V, class Hash = HashFunc<K>>
	class unordered_map
	{
	public:
		struct MapKeyOfT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
		typedef typename bucket_sqy::HashTable<K, pair<K, V>, Hash, MapKeyOfT>::iterator iterator;
		iterator begin() 
		{
			return _ht.begin();
		}
		iterator end() 
		{
			return _ht.end();
		}
		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			return _ht.Insert(kv);
		}
		V& operator[](const K& key)
		{
            std::cout << "调用[]重载函数" << std::endl;
			pair<iterator, bool> ret = insert(make_pair(key, V()));
			return ret.first->second;
		}
	private:
		bucket_sqy::HashTable<K, pair<K, V>, Hash,MapKeyOfT>_ht;
	};
	void Test_map()
	{
		//	string arr[] = { "苹果","葡萄", "香蕉", "苹果", "苹果", "葡萄", "苹果", "香蕉", "苹果", "香蕉", "苹果", "葡萄" };
		   //  int a[] = { 1,11,4,15,26,7,44,9 };
			unordered_map<int, int> h;
			//for (auto& e : a)
			// {
				h[1]++;
			// }
	//		for (auto& t : h)
	//		{
	//			cout << t.first<< endl;
	//		}
	}
}
